/****************************************************************************

Force Engine v0.5

Creado: 01/05/09
Clase: DrawUtilities.h
Hecho by: Maxi Carrion

****************************************************************************/
//---------------------------------------------------------------------------
#ifndef	_DRAWUTILITIES_H_
#define	_DRAWUTILITIES_H_
//---------------------------------------------------------------------------
inline HRESULT Draw3DLine(float x1, float y1, float z1, float x2, float y2, float z2, Graphics &rkGraphics)
{
	if(rkGraphics.GetDevice() == NULL)
	{
		return E_FAIL;
	}
	else
	{
		D3DXMATRIX projMatrix;
		D3DXMATRIX viewMatrix;

		D3DXVECTOR3 vLine[2];
		vLine[0].x = x1;
		vLine[0].y = y1;
		vLine[0].z = z1;

		vLine[1].x = x2;
		vLine[1].y = y2;
		vLine[1].z = z2;

		rkGraphics.GetDevice()->GetTransform(D3DTS_PROJECTION, &projMatrix);
		rkGraphics.GetDevice()->GetTransform(D3DTS_VIEW,&viewMatrix);
		D3DXMatrixMultiply(&projMatrix,&viewMatrix,&projMatrix);
		rkGraphics.GetDevice()->DrawPrimitiveUP(D3DPT_LINESTRIP, 2, &vLine, sizeof(D3DXVECTOR3));
	}
}
//---------------------------------------------------------------------------
inline HRESULT Draw3DLine(D3DXVECTOR3 v1, D3DXVECTOR3 v2, Graphics &rkGraphics)
{
	if(rkGraphics.GetDevice() == NULL)
	{
		return E_FAIL;
	}
	else
	{
		D3DXMATRIX kProjMatrix;
		D3DXMATRIX kViewMatrix;

		D3DXVECTOR3 vLine[2];
		vLine[0].x = v1.x;
		vLine[0].y = v1.y;
		vLine[0].z = v1.z;

		vLine[1].x = v2.x;
		vLine[1].y = v2.y;
		vLine[1].z = v2.z;

		rkGraphics.GetDevice()->GetTransform(D3DTS_PROJECTION, &kProjMatrix);
		rkGraphics.GetDevice()->GetTransform(D3DTS_VIEW, &kViewMatrix);
		D3DXMatrixMultiply(&kProjMatrix, &kViewMatrix, &kProjMatrix);
		rkGraphics.GetDevice()->DrawPrimitiveUP(D3DPT_LINESTRIP, 2, &vLine, sizeof(D3DXVECTOR3));

		return S_OK;
	}
}
//---------------------------------------------------------------------------
#endif /*---_DRAWUTILITIES_H_---*/
//---------------------------------------------------------------------------